import http from '@/utils/request'

/**
 * 获取部门信息
 * @returns
 */
export function reqGetDepartments() {
  return http({
    method: 'get',
    url: '/company/department'
  })
}

/**
 * 根据id删除部门
 */
export function reqDelDepartment(id) {
  return http({
    method: 'delete',
    url: `/company/department/${id}`
  })
}

/**
 * 新增一个部门
 * @param {*} obj {pid, name, code, manager, introduce}
 * @returns
 */
export function reqAddDepartment(obj) {
  return http({
    method: 'post',
    url: '/company/department',
    data: obj
  })
}

/**
 * 根据部门id获取部门详情数据
 * @param {*} id
 */
export function reqGetDepartDetail(id) {
  return http({
    method: 'get',
    url: `/company/department/${id}`
  })
}

/**
 * 根据部门id修改部门信息
 * @param {*} form 要修改的表单数据
 * @returns
 */
export function reqUpdateDepartDetail(form) {
  // post put --> data
  // get delete ---> params
  return http({
    method: 'put',
    url: `/company/department/${form.id}`,
    data: form
  })
}
